<?php /* Smarty version Smarty-3.1.6, created on 2018-06-09 16:16:42
         compiled from "D:/phpStudy/PHPTutorial/WWW/myshop/Home/View\IntegralGoods\tankgame.html" */ ?>
<?php /*%%SmartyHeaderCode:12112283715b1a0b6c2d3738-58392335%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '675fd85fccbb3216007567395fbed06e768e3202' => 
    array (
      0 => 'D:/phpStudy/PHPTutorial/WWW/myshop/Home/View\\IntegralGoods\\tankgame.html',
      1 => 1528532177,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '12112283715b1a0b6c2d3738-58392335',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.6',
  'unifunc' => 'content_5b1a0b6c2f807',
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_5b1a0b6c2f807')) {function content_5b1a0b6c2f807($_smarty_tpl) {?><!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="<?php echo @PUBLIC_PATH;?>
js/jquery.min.js"></script>
		<!--<script src="<?php echo @PUBLIC_PATH;?>
js/tankClass.js"></script>-->
	</head>
	<body onkeydown="move()" >
		<canvas id="maincan" width="500px" height="500px" style="border: 1px solid red;background-color: black;"></canvas>
		<script src="<?php echo @PUBLIC_PATH;?>
js/tankClass.js"></script>
		<script>
			var maincan=document.getElementById("maincan");
			var cxt=maincan.getContext("2d");
			var herobullets=new Array();
			
			var herotank=new hero(10,10,2,5,heroColor);
			var enemytanks=new Array();
			for(var i=0;i<3;i++){
				var enemytank=new enemy((120*i),200,0,5,enemyColor);
				enemytanks[i]=enemytank;
			}
			//刷新作战区域
			function flusharea(){
				cxt.clearRect(0,0,500,500);
				drawtank(herotank);
				drawbullet();
//				console.log(herobullet.x)
				for(var i=0;i<enemytanks.length;i++){
//					randommove(enemytanks[i]);
					//判断是否击中
					if(herobullets.length!=0)
					ishit(herobullets[0],enemytanks[i]);//判断是否击中敌军
					drawtank(enemytanks[i]);
				}
			}
			function enemyrandommove(){
					for(var i=0;i<enemytanks.length;i++){
						randommove(enemytanks[i]);
					}
				}
//			drawtank(enemytank,65);
			flusharea();
			function move(){
				var code=event.keyCode;
				switch(code){
					case 87:
					herotank.moveUp();
					break;
					case 68:
					herotank.moveRight();
					break;
					case 83:
					herotank.moveDown();
					break;
					case 65:
					herotank.moveLeft();
					break;
					case 74:
						if(herobullets.length<1)//最大发射子弹数
						herotank.shot();
					break;
				}
				
				window.setInterval("flusharea()",100);
//				flusharea();
			}
//			window.setInterval("herotank.moveDown()",1000);
			enemyrandommove();
		</script>
	</body>
</html>
<?php }} ?>